﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ecpIncluirContratoFrota.aspx.cs" Inherits="Protegidos_Empresas_Cadastros__popup_ecpIncluirContratoFrota" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register TagPrefix="uc1" TagName="HeadTag"  Src="~/_includes/HeadTag.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <!-- Includes -->
    <uc1:HeadTag ID="HeadTag1" runat="server" />            
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <telerik:RadProgressManager ID="RadProgressManager1" runat="server" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function CloseAndRebind(args)
            {
                GetRadWindow().Close();
                GetRadWindow().BrowserWindow.refreshGrid(args);
            }
    		
            function GetRadWindow()
            {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
    				
                return oWindow;
            }

            function CancelEdit()
            {
                GetRadWindow().Close();
            }
        </script>
        </telerik:RadCodeBlock>
        
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnBuscarVeiculo">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="trVeiculosSel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculos" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculosSel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="trMensagem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>  
            <telerik:AjaxSetting AjaxControlID="btnAdicionarItem">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculos" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculosSel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="trMensagem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>                                                           
            <telerik:AjaxSetting AjaxControlID="btnRemoverItem">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculos" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculosSel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="trMensagem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rgVeiculos">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculos" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="trMensagem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>                                                           
            <telerik:AjaxSetting AjaxControlID="rgVeiculosSel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgVeiculosSel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="trMensagem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>                                                           
        </AjaxSettings>
        </telerik:RadAjaxManager>

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Telerik" >
        </telerik:RadAjaxLoadingPanel> 

        <table width="99%" align="right">
            <tr id="trTitulo" runat="server">
                <td>
                    <div class="SuTituloVR">Controle de Frotas</div>
                </td>
            </tr>
            
            <tr id="trMensagem" runat="server" visible="false">
                <td valign="middle" style="background-color:#FFFFAA; height:33px">
                    &nbsp;&nbsp;<asp:Label ID="lblResultado" runat="server" Text="" Font-Names="Verdana" Font-Size="9"></asp:Label>
                </td>
            </tr>  
            
            <tr>
                <td>
                    <table>
                        <tr id="trContrato" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Contrato:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbContrato" runat="server" Skin="Telerik" DataTextField="Descricao"
                                    DataValueField="IdContrato" Font-Names="Verdana" EmptyMessage="Selecione uma opção" HighlightTemplatedItems="true"
                                    AllowCustomText="true" Width="240px" Height="160px">
			                    </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr id="trLocalidade" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Localidade:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbLocalidade" runat="server" Skin="Telerik" DataTextField="NomeCidade"
                                    DataValueField="IdCidade" Font-Names="Verdana" EmptyMessage="Selecione uma opção" HighlightTemplatedItems="true"
                                    AllowCustomText="true" Width="240px" Height="160px">
			                    </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr id="trLimiteKM" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Limite km:</span></td>
                            <td><asp:TextBox ID="txtLimiteKM" runat="server" Font-Names="Verdana" Text="" MaxLength="300" Width="240px"></asp:TextBox></td>
                        </tr>
                        <tr id="trAnoFabricacao" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Limite Ano Fabricação:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbAnoFab" runat="server" Skin="Telerik" DataTextField="Descricao"
                                    DataValueField="IdLimiteAnoFabricacao" Font-Names="Verdana" EmptyMessage="Selecione uma opção" HighlightTemplatedItems="true"
                                    AllowCustomText="true" Width="240px" Height="160px">
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                        <tr id="trQtdeMin" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Quantidade mínima de veículos:</span></td>
                            <td><asp:TextBox ID="txtQtdeMin" runat="server" Font-Names="Verdana" Text="" MaxLength="300" Width="100px"></asp:TextBox></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr id="trTituloVeiculos" runat="server">
                <td>
                    <div class="SuTituloVR">Seleção de Veículos</div>
                </td>
            </tr>
            <tr>
                <td>
                    <table>
                        <tr id="trFabricante" runat="server">
                            <td style="width: 200px"><span class="textoCZ_12">Fabricante:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbFabricante" runat="server" Skin="Telerik" Width="240px" Height="160px"
                                    EmptyMessage="Selecione um fabricante" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
                                    EnableVirtualScrolling="true" OnItemsRequested="rcbFabricante_ItemsRequested"
                                    LoadingMessage="Carregando...">
                                </telerik:RadComboBox>
                            </td>
                            <td>
                                <asp:Button ID="btnBuscarVeiculo" runat="server" Text="Buscar" onclick="btnBuscarVeiculo_Click"/>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="99%" align="right">
                        <tr id="trVeiculosSel" runat="server">
                            <td>
                                <telerik:RadGrid ID="rgVeiculos" Width="250px" Height="200px" Skin="Telerik" 
                                    runat="server" AllowPaging="false" AllowSorting="true" AllowMultiRowSelection="true"
                                    GridLines="None"  AutoGenerateColumns="false"
                                    OnNeedDataSource="rgVeiculos_NeedDataSource">
                                    <MasterTableView GridLines="None" DataKeyNames="IdFrotaModelo" Name="TableViewVeiculos">
                                        <Columns>
                                            <telerik:GridBoundColumn UniqueName="Veiculo" HeaderText="Veículo" DataField="Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings EnableRowHoverStyle="true">
                                        <Selecting AllowRowSelect="true" />
                                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" FrozenColumnsCount="1"></Scrolling>
                                    </ClientSettings>
                                </telerik:RadGrid>
                            </td>
                            <td>
                                <table align="center">
                                    <tr>
                                        <td><asp:Button ID="btnAdicionarItem" runat="server" Text=">>" onclick="btnAdicionarItem_Click" /></td>
                                    </tr>
                                    <tr>
                                        <td><asp:Button ID="btnRemoverItem" runat="server" Text="<<" onclick="btnRemoverItem_Click" /></td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                                <telerik:RadGrid ID="rgVeiculosSel" Width="300px" Height="200px" Skin="Telerik"
                                    runat="server" AllowPaging="false" AllowSorting="true" AllowMultiRowSelection="true"
                                    GridLines="None" AutoGenerateColumns="false"
                                    OnNeedDataSource="rgVeiculosSel_NeedDataSource">
                                    <MasterTableView GridLines="None" DataKeyNames="IdFrotaModelo" Name="TableViewVeiculosSel">
                                        <Columns>
                                            <telerik:GridBoundColumn UniqueName="Fabricante" HeaderText="Fabricante" DataField="Fabricante.Descricao" HeaderStyle-Width="80px" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="Veiculo" HeaderText="Veículo" DataField="Descricao" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings EnableRowHoverStyle="true">
                                        <Selecting AllowRowSelect="true" />
                                        <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" FrozenColumnsCount="1"></Scrolling>
                                    </ClientSettings>
                                </telerik:RadGrid>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="right">
                <br />
                    <asp:Button ID="btnGravar" runat="server" Text="Gravar" Width="110px" onclick="btnGravar_Click" />&nbsp;&nbsp;
                    <asp:Button ID="btnFechar" runat="server" Text="Fechar" Width="110px" onclick="btnFechar_Click" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
